package cn.lu.train.util;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.util.Base64;

public class Secure {

    public static String getApkSignature(Context context) {
        try {
            // 获取apk签名做密钥种子
            PackageInfo packageInfo = context
                    .getPackageManager()
                    .getPackageInfo(context.getPackageName(), PackageManager.GET_SIGNATURES);

            return Base64.encodeToString(packageInfo.signatures[0].toByteArray(), Base64.NO_WRAP);
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
            return null;
        }
    }
}
